﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using System.Data.SqlClient;
using System.Data;
using System.Collections;

using XJX.BusinessLayer;

namespace XJX.Page
{
    /// <summary>
    ///Books 的摘要说明
    /// </summary>
    public class Exchange
    {
        public Exchange()
        {
            //
            //TODO: 在此处添加构造函数逻辑
            //
        }

        static string str = System.Configuration.ConfigurationManager.ConnectionStrings["DataConn"].ConnectionString;

        static XJX.BusinessLayer.Exchange bs = new XJX.BusinessLayer.Exchange(str);

        public static bool Add_New_ExchangeTheme
            (
            string Title,
            string Content,
            string UID,
            out int ReturnValue,          //返回参数值
            out string ReturnFieldValue   //返回字段值,返回插入的新值ID编号
            )
        {
            bool b;

            try
            {
                b = bs.Add_New_ExchangeTheme(Title, Content, UID, out ReturnValue, out ReturnFieldValue);
            }
            catch (SqlException e)
            {
                throw new System.Exception(e.Message);
            }
            return b;
        }


        public static bool Del_One_ExchangeTheme_From_EXID(string EXID,string UID)
        {
            bool b;

            try
            {
                b = bs.Del_One_ExchangeTheme_From_EXID(EXID,UID);
            }
            catch (SqlException e)
            {
                throw new System.Exception(e.Message);
            }
            return b;
        }

        public static bool Modify_One_ExchangeTheme_Info
            (
            string EXID,
            string UID,
            string Title,
            string Content
            )
        {
            bool b;

            try
            {
                b = bs.Modify_One_ExchangeTheme_Info(EXID,UID,Title,Content);
            }
            catch (SqlException e)
            {
                throw new System.Exception(e.Message);
            }
            return b;
        }

        //得到一个交流主题的内容
        public static string Get_One_ExchangeTheme_Info_From_EXID(string EXID)
        {
            Hashtable ht = bs.Get_One_ExchangeTheme_Info_From_EXID(EXID);
            return XJX.BusinessLayer.JSON.Encode(ht);
        }

        //得到某个家庭发表的所有交流主题标题列表
        public static string Get_One_Family_All_ExchangeTheme_List
            (
            string UID,
            string Title,

            int PageIndex,
            int PageSize
            )
        {
            Hashtable ht = bs.Get_One_Family_All_ExchangeTheme_List(UID,Title,PageIndex,PageSize);
            return XJX.BusinessLayer.JSON.Encode(ht);
        }


        //一般浏览用户或者管理员获取交流主题的标题列表
        public static string Get_ExchangeTheme_List
            (
            string Title,
            string IsAll,

            int PageIndex,
            int PageSize
            )
        {
            Hashtable ht = bs.Get_ExchangeTheme_List(Title,IsAll, PageIndex, PageSize);
            return XJX.BusinessLayer.JSON.Encode(ht);
        }

        //屏蔽或显示一条交流主题
        public static bool ShieldORDisp_One_ExchangeTheme_By_EXID
        (
            string EXID,
            out int ReturnValue,
            out string ReturnFieldValue
            )
        {
            bool b;

            try
            {
                b = bs.ShieldORDisp_One_ExchangeTheme_By_EXID(EXID, out ReturnValue, out ReturnFieldValue);
            }
            catch (SqlException e)
            {
                throw new System.Exception(e.Message);
            }
            return b;
        }


        //置顶一条交流主题
        public static bool StickORCannel_One_ExchangeTheme_By_EXID
        (
            string EXID,
            out int ReturnValue,
            out string ReturnFieldValue
            )
        {
            bool b;

            try
            {
                b = bs.StickORCannel_One_ExchangeTheme_By_EXID(EXID, out ReturnValue, out ReturnFieldValue);
            }
            catch (SqlException e)
            {
                throw new System.Exception(e.Message);
            }
            return b;
        }
    }
}